<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of owltheme
 *
 * @author trung
 */
class Owl_Theme extends Owl_Db{
    
    var $setting_cache;
    
    function Owl_Theme($theme_name = false){
        if ($theme_name)
            $theme_setting = THEME_PATH.$theme_name."/setting.xml";
        else
            $theme_setting = THEME_PATH."default/setting.xml";
        $this->Owl_Db("theme",$theme_setting,SCHEMA_PATH."theme.xsd");
    }
    
    function get_all_settings(){
        $setting = $this->get_row('//setting');
        if ($setting)
            $this->setting_cache = $setting;
        else
            $this->setting_cache = array();
        return $this->setting_cache;
    }

    function get_setting($name, $default = false){
       if (!isset ($this->setting_cache)){
             $this->get_all_settings();
         }
         if (isset ($this->setting_cache[$name])){
             $value = $this->setting_cache[$name];
             return $value;
         } else {
             return $default;
         }
    }
}

